#ifndef YCBASETYPE_H
#define YCBASETYPE_H
#include <QLocale>
#include <QtCore/qglobal.h>

namespace yc {

enum ErrorCode {
    OK_CODE = 200,
    REFRESH_TOKEN_INVALID_ERROR = 400,
    UNAUTHORIZED_ERROR = 401,
    FORBIDDEN_ERROR = 403,
    INTERNAL_SERVER_ERROR = 500,
    TOKEN_EXPIRED = 501,
    OPEN_ERROR,
    CANCEL_ERROR,
    LOGIC_ERROR,
    TIMEOUT_ERROR,
    DEVICE_ERROR,
    NETWORK_ERROR,
    SERVICE_ERROR,
    USER_ERROR = 5000,
};

enum SecurityType {
    PUBLIC_SECURITY_TYPE,
    PRIVATE_SECURITY_TYPE,
};

enum EnvType { PROD_ENV_TYPE, DEV_ENV_TYPE, TEST_ENV_TYPE };

// c++17
struct BaseConstants
{
    static inline constexpr qint64 KILO_BYTE = 1024;
    static inline constexpr qint64 MILLION_BYTE = 1024 * KILO_BYTE;
    static inline constexpr qint64 GIGA_BYTE = 1024 * MILLION_BYTE;
    static inline constexpr qint64 SMALL_FILE_SIZE = 50 * MILLION_BYTE;
};

struct LanguageScript
{
    QLocale::Language language;
    QLocale::Script script;

    LanguageScript()
    {
        // language switch
        QLocale l = QLocale::system();
        QStringList sl = l.uiLanguages();
        if (!sl.empty() && sl.first().startsWith("en", Qt::CaseInsensitive)) {
            language = QLocale::English;
        } else {
            language = QLocale::Chinese;
        }
        script = l.script();
    }

    LanguageScript(QLocale::Language l, QLocale::Script s) : language(l), script(s) { }
};

} // namespace yc

#endif // YCBASETYPE_H
